package com.wsj.neo4j.simple.controller;

import com.wsj.neo4j.simple.mds.entity.Company;
import com.wsj.neo4j.simple.mds.repository.CompanyRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @author WangSongJun
 * @date 2019-10-28
 */
@RestController
@RequestMapping("company")
public class CompanyController {
    @Autowired
    private CompanyRepository companyRepository;

    @GetMapping("add")
    public Company add() {
        String name = UUID.randomUUID().toString().substring(0, 8);
        Company company = new Company();
        company.setName(name);

        Company save = this.companyRepository.save(company);

        return save;
    }

}
